<template>
	<view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				paraString:"",
				orderId:"",
				transactionId:""
			}
		},
		onLoad() {
			uni.showLoading({
				mask: true,
				title: "請稍後"
			})
			this.paraString = window.location.href //还可以  window.location.search.substring()
			this.orderId = this.getQueryVariable('orderId') //code是url後面带的
			this.transactionId = this.getQueryVariable('transactionId') //code是url後面带的
			this.linepay()
			console.log(this.paraString,"原来鏈接",this.orderId,"orderId",this.transactionId,"transactionId");
		},
		methods: {
			linepay(){
				this.http.request('/api/Shopwelfarecl/linePayPrice', 'GET', {
					orderId:this.orderId,
					transactionId:this.transactionId
				}).then(res => {
					uni.hideLoading()
					this.http.toast(res.msg)
					if (res.code == 1) {
						setTimeout(()=>{
							window.location = "https://boss.opos.tw"
						},1000)
					}
				})
			},
			getQueryVariable(variable) {
				var query = this.paraString;
				var rooms = query.split('?');
				for (var i = 0; i < rooms.length; i++) {
					var pair = rooms[i].split('=');
					if (pair[0] == variable) {
						return (pair[1].split('&'))[0]
					}
				}
				//或者拼接&後面的值
				var vars = query.split('&')
				for (var i = 0; i < vars.length; i++) {
					var pair = vars[i].split('=')
					if (pair[0] == variable) {
						return pair[1]
					}
				}
			},
		}
	}
</script>

<style>

</style>
